package com.itsc.dao;

import java.util.List;

import org.hibernate.Query;

import com.itsc.entities.Product;

@SuppressWarnings("unchecked")
public class ProductDao extends BaseDao<Product>{

	/**
	 * 根据名称，查询id
	 * @param name
	 * @return
	 */
	public Integer checkProByName(String hql, String name){
		Query query = getSession().createQuery(hql);
		query.setString(0, name);
		List<Product> list = query.list();
		Integer id = list.get(0).getPro_id();
		return id;
	}
	
	public Boolean checkByName(String hql, String name){
		Query query = getSession().createQuery(hql);
		query.setString(0, name);
		List<Product> list = query.list();
		if(list.size()!=0){
			return false;
		}else{
			return true;
		}
	}
}
